# 从MySQL获取symbol列表的SQL
from web_crawler.utils import MySQLPool

SYMBOL_SQL = """
          SELECT distinct symbol FROM xueqiu_stocks """


def _fetch_symbols_from_db():
    """从MySQL获取symbol列表"""
    conn = MySQLPool().get_conn()

    try:
        with conn.cursor() as cursor:
            cursor.execute(SYMBOL_SQL)
            return cursor.fetchall()
    finally:
        conn.close()

if __name__ == '__main__':
    symbols = _fetch_symbols_from_db()
    for symbol in symbols:
        print(symbol)